import random  # 导入随机数的模块 random
all_choices = ["石头", "剪刀", "布"]  # 存储出拳的每个选择
win_list = [["石头", "剪刀"], ["剪刀", "布"], ["布", "石头"]]
pwin = 0  # 表示玩家获胜的次数
cwin = 0  # 表示计算机获胜的次数

while pwin < 2 and cwin < 2:
    # 表示一局游戏开始
    computer = random.choice(all_choices)
    print("computer:", computer)
    player = input("请出拳(石头/剪刀/布):")
    if player == computer:
        print("平局")
    elif [player, computer] in win_list:
        print("玩家胜")
        pwin += 1  # 玩家获胜次数+1
    else:
        print("计算机胜")
        cwin += 1  # 计算机获胜次数+1